package a4_dichteste_ecke;

import java.util.ArrayList;

import a1_graph_lib.AIGraphCounter;

public class SortetEdges {

	final private String KOSTEN = "0";
	ArrayList<Integer> edges;
	int index;
	
	public SortetEdges(AIGraphCounter graph) {
		index = 0;
		edges = new ArrayList<Integer>();
		ArrayList<Integer> temp = graph.getEdges();
		
		while(!temp.isEmpty()){
			
			int temp_edge =temp.get(0);
			for(int edge : temp){
				if(graph.getValE(temp_edge, KOSTEN) > graph.getValE(edge, KOSTEN)){
					temp_edge = edge;
				}
			}
			
			temp.remove(temp.indexOf(temp_edge));
			edges.add(temp_edge);
		}
	}

	public boolean isEmpty() {
		if(index < edges.size()){
			return false;
		}
		return true;
	}

	public int getGuenstigste() {
		index++;
		return edges.get(index-1);
	}
	
	public void resetIndex() {
		index = 0;
	}

}
